<%@ include file="/common/taglibs.jsp"%>
<%@ include file="/common/loginredirect.jsp"%>
<head>
    <title> <fmt:message key="menu.prijava"/></title>
    <meta name="heading" content="<fmt:message key='workPosition.workPosition'/>" />
     <meta name="menu" content="FormsMenu"/>
</head>





<div class="jquery_tab_container">
    <span class="heading_tab advanced_link active tab1"><fmt:message key="menu.prijava"/></span>
</div>

<div class="jquery_tab">
    <div class="content_block"></div>



<form:form class="popupDeleteForm" commandName="workPositionForm" name="workPositionFormPrijava" method="post" action="workpositionformprijava" id="workPositionFormPrijava" onsubmit="return validateWorkPositionForm(this)">
<form:errors path="*" cssClass="error" element="div"/>
<form:hidden path="workPosition.id"/>
        <p>
        <appfuse:label styleClass="width150 left" key="basicInfo.firstName"/>
        <form:input path="workPosition.employment.firstName" id="workPosition.employment.firstName" disabled="true" style="background-color: #ccc;" cssClass="input-medium left toCyr" cssErrorClass="text medium error" maxlength="50"/>
        <form:errors path="workPosition.employment.firstName" cssClass="fieldError"/>
        <br class="clearboth" />
        </p>
        <p>
        <appfuse:label styleClass="width150 left" key="basicInfo.lastName"/>
        <form:input path="workPosition.employment.lastName" id="workPosition.employment.lastName" disabled="true" style="background-color: #ccc;" cssClass="input-medium left toCyr" cssErrorClass="text medium error" maxlength="50"/>
        <form:errors path="workPosition.employment.lastName" cssClass="fieldError"/>
        <br class="clearboth" />
    </p>
        <p>
        <appfuse:label styleClass="width150 left" key="basicInfo.socScrNo"/>
        <form:input path="workPosition.employment.socScrNo" id="workPosition.employment.socScrNo" disabled="true" style="background-color: #ccc;" cssClass="left input-medium toCyr" cssErrorClass="text medium error" maxlength="50"/>
        <form:errors path="workPosition.employment.socScrNo" cssClass="fieldError"/>
          <br class="clearboth" />
 </p>
        <p>
         <appfuse:label styleClass="width150 left" key="workPosition.institution"/>
        
         <form:input id="institution" path="workPosition.institution.institutionName"  cssStyle="width: 600px;" cssClass="left input-medium toCyr" cssErrorClass="text medium error" />
         <form:hidden id="institutionId" path="workPosition.institution.id"/>
        <form:hidden path="workPosition.discriminator" id="workPosition.discriminator" cssClass="text medium" cssErrorClass="text medium error" value="1" /> 
             <br class="clearboth" />
 </p>
        <p>
        <appfuse:label styleClass="width150 left" key="workPosition.position"/>
        <form:input path="workPosition.position" id="workPosition.position" cssClass="left input-medium toCyr" cssErrorClass="text medium error"/>
        <form:errors path="workPosition.position" cssClass="fieldError"/>
         <br class="clearboth" />
   </p>
        <p>
        <appfuse:label styleClass="width150 left" key="workPosition.trialPeriod"/>
        <form:checkbox path="workPosition.trialPeriod" id="workPosition.trialPeriod" cssClass="left input-medium" cssErrorClass="text medium error" />
        <form:errors path="workPosition.trialPeriod" cssClass="fieldError"/>
                  <br class="clearboth" />
        </p>
        <p>
        <appfuse:label styleClass="width150 left" key="workPosition.posType"/>
        <form:select path="workPosition.posType.id" id="posTypeSelect" cssClass="left input-medium" >
                <form:option id="1" value="">
                    <fmt:message key='posTypeSearch'/>
                </form:option>
                <c:forEach items="${workPositionForm.posType}" var="posType">

                   <c:if test="${posType == workPositionForm.workPosition.posType}">
                        <form:option value="${posType.id}" id="${workPositionForm.workPosition.posType.id}" selected="true">
                            ${posType.posTypeName}
                        </form:option>
                   </c:if>
                    <c:if test="${posType != workPositionForm.workPosition.posType}">
                        <form:option value="${posType.id}" id="${workPositionForm.workPosition.posType.id}" >
                            ${posType.posTypeName}
                            </form:option>
                    </c:if>
                </c:forEach>
         </form:select>
         <br class="clearboth" />
 </p>
        <p>
        <appfuse:label styleClass="width150 left" key="workPosition.startDate"/>
        <form:input path="workPosition.startDate" value="" name="flexy_datepicker" id="workPosition.startDate" cssClass="input-medium left flexy_datepicker_input" cssErrorClass="text medium error" maxlength="50"/>
        <form:errors path="workPosition.startDate" cssClass="fieldError"/>
        <br class="clearboth" />
    </p>
        <p>
        <appfuse:label styleClass="width150 left" key="workPosition.employmentReason"/>
        <form:select path="workPosition.emplReason.id" id="employmentReasonSelect">
                <form:option id="1" value="">
                    <fmt:message key='emplReasonSearch'/>
                </form:option>
                <c:forEach items="${workPositionForm.employmentReason}" var="employmentReason">

                   <c:if test="${employmentReason == workPositionForm.workPosition.emplReason}">
                        <form:option value="${employmentReason.id}" id="${workPositionForm.workPosition.emplReason.id}" selected="true">
                            ${employmentReason.name}
                        </form:option>
                   </c:if>
                    <c:if test="${employmentReason != workPositionForm.workPosition.emplReason}">
                        <form:option value="${employmentReason.id}" id="${workPositionForm.workPosition.emplReason.id}" >
                            ${employmentReason.name}
                            </form:option>
                    </c:if>
                </c:forEach>
         </form:select>
         <br class="clearboth" />
    </p>
        <p>
        <appfuse:label styleClass="width150 left" key="workPosition.experience"/>
        <form:input path="workPosition.experience" id="workPosition.experience" cssClass="left input-medium toCyr" cssErrorClass="text medium error" maxlength="50"/>
        <form:errors path="workPosition.experience" cssClass="fieldError"/>
        <br class="clearboth" />
 </p>
     
  <form:hidden id="reasonDelete" path="savedReason.id"/>
  
    <p class="buttonBar bottom">
        <c:if test="${workPositionForm.isEditable == true}">
          <input type="submit" class="button"  name="save" value="<fmt:message key="button.save"/>"/>
           </c:if>
        <c:if test="${not empty workPositionForm.workPosition.id and workPositionForm.isEditable == true}">          
        <input type="button" class="button" onclick="confirmDelete();"
            value="<fmt:message key="button.delete"/>" />
        </c:if>
        <input type="button" class="button" name="cancel" value="<fmt:message key="button.cancel"/>"  onclick="location.href='<c:url value="/workpositionsearch"/>'"  />
    </p>

</form:form>

<v:javascript formName="workPositionForm" cdata="false" dynamicJavascript="true" staticJavascript="false"/>
<script type="text/javascript" src="<c:url value='/scripts/validator.jsp'/>"></script>


    <script type="text/javascript">
 new Autocomplete('institution', {
    serviceUrl:'<c:url value="/hello.json" />',
    minChars:2,
    clazz: "Institution",
    parent: "",
    maxHeight:500,
    width:600,
    deferRequestBy:300,
    // callback function:
    onSelect: function(value, data){
        jQuery("#institutionId").val(data);
    }
  });

  jQuery("#institution").blur( function () {
            if (jQuery("#institutionId").val() == "") {
                jQuery(this).val("");
            }
  });
</script>

<div id="confirmdelete">    
    <fmt:message key="delete.reasonDescription" />
    <select id="deleteReasonId">
        <c:forEach items="${workPositionForm.deleteReason}" var="reason">
             <option value="${reason.id}">
                ${reason.name}
             </option>
        </c:forEach>
    </select>
</div>
    
</div>